package org.jeecg.modules.nongjt.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.nongjt.entity.NjtUserRegister;
import org.jeecg.modules.nongjt.service.INjtUserRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * <p>
 * 用户注册信息 前端控制器
 * </p>
 *
 * @author yaorange
 * @since 2022-06-15
 */
@RestController
@RequestMapping("/user/njtUserRegister")
public class NjtUserRegisterController {
    @Autowired
    private INjtUserRegisterService njtUserRegisterService;
    /**
     * 分页列表查询
     *
     * @param njtUserRegister
     * @param pageNum
     * @param pageSize
     * @param
     * @return
     */
    @GetMapping("/page")
    public Result<?> getPage(@RequestParam(defaultValue = "1") Integer pageNum,
                          @RequestParam(defaultValue = "5") Integer pageSize,
                          NjtUserRegister njtUserRegister){
        //设置分页参数
        Page<NjtUserRegister> page = new Page<>(pageNum, pageSize);
        //设置分页查询条件
        QueryWrapper<NjtUserRegister> queryWrapper = new QueryWrapper<>();
        //主体名称模糊查询
        if (njtUserRegister !=null){
            if (!StringUtils.isEmpty(njtUserRegister.getCompanyName())){
                queryWrapper.like("company_name",njtUserRegister.getCompanyName());
            }
            if(!StringUtils.isEmpty(njtUserRegister.getMobilePhone())){
                queryWrapper.eq("mobile_phone",njtUserRegister.getMobilePhone());
            }
            if(!StringUtils.isEmpty(njtUserRegister.getMemberFlag())){
                queryWrapper.eq("member_flag",njtUserRegister.getMemberFlag());
            }
            if(!StringUtils.isEmpty(njtUserRegister.getUserStatus())){
                queryWrapper.eq("user_status",njtUserRegister.getUserStatus());
            }
        }
        //调用service底层提供的分页查询方法
        njtUserRegisterService.page(page,queryWrapper);
        //封装返回数据
        return Result.ok(page);
    }




}

